/*
 * Copyright (c) 2025 Li Auto Inc. and its affiliates
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef DSFDDS_SHARED_QUEUE_TRANSPORT_DESCRIPTOR_H
#define DSFDDS_SHARED_QUEUE_TRANSPORT_DESCRIPTOR_H

#include <cstdint>

#include "xmlparser/qos/XMLQosPolicies.hpp"
#include "xmlparser/transport_descriptors/transport_descriptor_interface.h"

namespace vbsutil {
namespace xmlparser {

class SharedQueueTransportDescriptorPart : public TransportDescriptorInterfacePart {
 public:
    SharedQueueTransportDescriptorPart(QueueWakeUp wake_up_mode, uint32_t queue_size)
        : wake_up_mode_(wake_up_mode), queue_size_(queue_size), reliability_(RELIABLE_RELIABILITY_QOS) {}
    SharedQueueTransportDescriptorPart()
        : wake_up_mode_(PTHREAD_CONDITION_WAKE_UP), queue_size_(102400U), reliability_(RELIABLE_RELIABILITY_QOS) {}

    SharedQueueTransportDescriptorPart(const SharedQueueTransportDescriptorPart& descriptor)
        : wake_up_mode_(descriptor.wake_up_mode_),
          queue_size_(descriptor.queue_size_),
          reliability_(descriptor.reliability_) {}
    SharedQueueTransportDescriptorPart& operator=(const SharedQueueTransportDescriptorPart& rhs) {
        wake_up_mode_ = rhs.wake_up_mode_;
        queue_size_ = rhs.queue_size_;
        reliability_ = rhs.reliability_;
        return *this;
    }

    virtual ~SharedQueueTransportDescriptorPart() {}

    bool operator==(const SharedQueueTransportDescriptorPart& rhs) const {
        return wake_up_mode_ == rhs.wake_up_mode_ && queue_size_ == rhs.queue_size_ && reliability_ == rhs.reliability_;
    }

    //
    QueueWakeUp GetWakeUpMode() const { return wake_up_mode_; }
    void SetWakeUpMode(QueueWakeUp wake_up_mode) { wake_up_mode_ = wake_up_mode; }
    uint32_t GetQueueSize() const { return queue_size_; }
    void SetQueueSize(uint32_t queue_size) { queue_size_ = queue_size; }
    ReliabilityQosPolicyKind GetReliability() const { return reliability_; }
    void SetReliability(ReliabilityQosPolicyKind reliability) { reliability_ = reliability; }

 private:
    QueueWakeUp wake_up_mode_;
    uint32_t queue_size_;
    ReliabilityQosPolicyKind reliability_;
};

}  // namespace xmlparser
}  // namespace vbsutil

#endif  // DSFDDS_SHARED_QUEUE_TRANSPORT_DESCRIPTOR_H
